import numpy as np
import matplotlib.pyplot as plt
import pickle
f = open('negative sample.pickle', 'rb')
sampling = pickle.load(f)
createVar = locals()
i=1
while i<=100:
    createVar['d' + str(i)] = 0
    #print('elif i>={} and i<{}:'.format(a,a+step))
    i+=1
for i in sampling:
    if i >= -0.01 and i < -0.0056:
        d1+=1
    elif i >= -0.0056 and i < -0.0012:
        d2 += 1
    elif i >= -0.0012 and i < 0.0032:
        d3 += 1
    elif i >= 0.0032 and i < 0.0076:
        d4 += 1
    elif i >= 0.0076 and i < 0.012:
        d5 += 1
    elif i >= 0.012 and i < 0.0164:
        d6 += 1
    elif i >= 0.0164 and i < 0.0208:
        d7 += 1
    elif i >= 0.0208 and i < 0.0252:
        d8+=1
    elif i >= 0.0252 and i < 0.0296:
        d9 += 1
    elif i >= 0.0296 and i < 0.034:
        d10 += 1
    elif i >= 0.034 and i < 0.0384:
        d11 += 1
    elif i >= 0.0384 and i < 0.0428:
        d12 += 1
    elif i >= 0.0428 and i < 0.0472:
        d13 += 1
    elif i >= 0.0472 and i < 0.0516:
        d14 += 1
    elif i >= 0.0516 and i < 0.056:
        d15 += 1
    elif i >= 0.056 and i < 0.0604:
        d16 += 1
    elif i >= 0.0604 and i < 0.0648:
        d17 += 1
    elif i >= 0.0648 and i < 0.0692:
        d18 += 1
    elif i >= 0.0692 and i < 0.0736:
        d19 += 1
    elif i >= 0.0736 and i < 0.078:
        d20 += 1
    elif i >= 0.078 and i < 0.0824:
        d21 += 1
    elif i >= 0.0824 and i < 0.0868:
        d22 += 1
    elif i >= 0.0868 and i < 0.0912:
        d23 += 1
    elif i >= 0.0912 and i < 0.0956:
        d24 += 1
    elif i >= 0.0956 and i < 0.1:
        d25 += 1
    elif i >= 0.1 and i < 0.1044:
        d26 += 1
    elif i >= 0.1044 and i < 0.1088:
        d27 += 1
    elif i >= 0.1088 and i < 0.1132:
        d28 += 1
    elif i >= 0.1132 and i < 0.1176:
        d29 += 1
    elif i >= 0.1176 and i < 0.122:
        d30 += 1
    elif i >= 0.122 and i < 0.1264:
        d31 += 1
    elif i >= 0.1264 and i < 0.1308:
        d32 += 1
    elif i >= 0.1308 and i < 0.1352:
        d33 += 1
    elif i >= 0.1352 and i < 0.1396:
        d34 += 1
    elif i >= 0.1396 and i < 0.144:
        d35 += 1
    elif i >= 0.144 and i < 0.1484:
        d36 += 1
    elif i >= 0.1484 and i < 0.1528:
        d37 += 1
    elif i >= 0.1528 and i < 0.1572:
        d38 += 1
    elif i >= 0.1572 and i < 0.1616:
        d39 += 1
    elif i >= 0.1616 and i < 0.166:
        d40 += 1
    elif i >= 0.166 and i < 0.1704:
        d41 += 1
    elif i >= 0.1704 and i < 0.1748:
        d42 += 1
    elif i >= 0.1748 and i < 0.1792:
        d43 += 1
    elif i >= 0.1792 and i < 0.1836:
        d44 += 1
    elif i >= 0.1836 and i < 0.188:
        d45 += 1
    elif i >= 0.188 and i < 0.1924:
        d46 += 1
    elif i >= 0.1924 and i < 0.1968:
        d47 += 1
    elif i >= 0.1968 and i < 0.2012:
        d48 += 1
    elif i >= 0.2012 and i < 0.2056:
        d49 += 1
    elif i >= 0.2056 and i < 0.21:
        d50 += 1
    elif i >= 0.21 and i < 0.2144:
        d51 += 1
    elif i >= 0.2144 and i < 0.2188:
        d52 += 1
    elif i >= 0.2188 and i < 0.2232:
        d53 += 1
    elif i >= 0.2232 and i < 0.2276:
        d54 += 1
    elif i >= 0.2276 and i < 0.232:
        d55 += 1
    elif i >= 0.232 and i < 0.2364:
        d56 += 1
    elif i >= 0.2364 and i < 0.2408:
        d57 += 1
    elif i >= 0.2408 and i < 0.2452:
        d58 += 1
    elif i >= 0.2452 and i < 0.2496:
        d59 += 1
    elif i >= 0.2496 and i < 0.254:
        d60 += 1
    elif i >= 0.254 and i < 0.2584:
        d61 += 1
    elif i >= 0.2584 and i < 0.2628:
        d62 += 1
    elif i >= 0.2628 and i < 0.2672:
        d63 += 1
    elif i >= 0.2672 and i < 0.2716:
        d64 += 1
    elif i >= 0.2716 and i < 0.276:
        d65 += 1
    elif i >= 0.276 and i < 0.2804:
        d66 += 1
    elif i >= 0.2804 and i < 0.2848:
        d67 += 1
    elif i >= 0.2848 and i < 0.2892:
        d68 += 1
    elif i >= 0.2892 and i < 0.2936:
        d69 += 1
    elif i >= 0.2936 and i < 0.298:
        d70 += 1
    elif i >= 0.298 and i < 0.3024:
        d71 += 1
    elif i >= 0.3024 and i < 0.3068:
        d72 += 1
    elif i >= 0.3068 and i < 0.3112:
        d73 += 1
    elif i >= 0.3112 and i < 0.3156:
        d74 += 1
    elif i >= 0.3156 and i < 0.32:
        d75 += 1
    elif i >= 0.32 and i < 0.3244:
        d76 += 1
    elif i >= 0.3244 and i < 0.3288:
        d77 += 1
    elif i >= 0.3288 and i < 0.3332:
        d78 += 1
    elif i >= 0.3332 and i < 0.3376:
        d79 += 1
    elif i >= 0.3376 and i < 0.342:
        d80 += 1
    elif i >= 0.342 and i < 0.3464:
        d81 += 1
    elif i >= 0.3464 and i < 0.3508:
        d82 += 1
    elif i >= 0.3508 and i < 0.3552:
        d83 += 1
    elif i >= 0.3552 and i < 0.3596:
        d84 += 1
    elif i >= 0.3596 and i < 0.364:
        d85 += 1
    elif i >= 0.364 and i < 0.3684:
        d86 += 1
    elif i >= 0.3684 and i < 0.3728:
        d87 += 1
    elif i >= 0.3728 and i < 0.3772:
        d88 += 1
    elif i >= 0.3772 and i < 0.3816:
        d89 += 1
    elif i >= 0.3816 and i < 0.386:
        d90 += 1
    elif i >= 0.386 and i < 0.3904:
        d91 += 1
    elif i >= 0.3904 and i < 0.3948:
        d92 += 1
    elif i >= 0.3948 and i < 0.3992:
        d93 += 1
    elif i >= 0.3992 and i < 0.4036:
        d94 += 1
    elif i >= 0.4036 and i < 0.408:
        d95 += 1
    elif i >= 0.408 and i < 0.4124:
        d96 += 1
    elif i >= 0.4124 and i < 0.4168:
        d97 += 1
    elif i >= 0.4168 and i < 0.4212:
        d98 += 1
    elif i >= 0.4212 and i < 0.4256:
        d99 += 1
    elif i >= 0.4256 and i < 0.43:
        d100 += 1


x = np.arange(100)
yl = np.array([d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,d18,d19,d20,d21,d22,d23,d24,d25,d26,d27,d28,d29,d30,d31,d32,d33,d34,d35,d36,d37,d38,d39,d40,d41,d42,d43,d44,d45,d46,d47,d48,d49,d50,d51,d52,d53,d54,d55,d56,d57,d58,d59,d60,d61,d62,d63,d64,d65,d66,d67,d68,d69,d70,d71,d72,d73,d74,d75,d76,d77,d78,d79,d80,d81,d82,d83,d84,d85,d86,d87,d88,d89,d90,d91,d92,d93,d94,d95,d96,d97,d98,d99,d100])
bar_width = 0.3
ticks_label=['-0.01','-0.0056','-0.0012','0.0032','0.0076','0.012','0.0164','0.0208','0.0252','0.0296','0.034','0.0384','0.0428','0.0472','0.0516','0.056','0.0604','0.0648','0.0692','0.0736','0.078','0.0824','0.0868','0.0912','0.0956','0.1','0.104,4','0.1088','0.1132','0.1176','0.122','0.1264','0.1308','0.1352','0.1396','0.144','0.1484','0.1528','0.1572','0.1616','0.166','0.1704','0.1748','0.1792','0.1836','0.188','0.1924','0.1968','0.2012','0.2056','0.21','0.2144,''0.2188','0.2232','0.2276','0.232','0.2364','0.2408','0.2452','0.2496','0.254','0.2584','0.2628','0.2672','0.2716','0.276','0.2804','0.2848','0.2892','0.2936','0.298','0.3024','0.3068','0.3112','0.3156','0.32','0.3244,''0.3288','0.3332','0.3376','0.342','0.3464','0.3508','0.3552','0.3596','0.364','0.3684','0.3728','0.3772','0.3816','0.386','0.3904','0.3948','0.3992','0.4036','0.408','0.4124','0.4168','0.4212','0.4256']
plt.xticks(x[::10],ticks_label[::10])
plt.bar(x, yl, width=bar_width)
plt.show()